/*
 * 文件名：ConsumableUseRecordDaoImpl.java
 * 版权：Copyright by www.wootide.com
 * 描述：
 * 修改人：wuliquan
 * 修改时间：2013-2-26
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */
package com.wootide.cms.service.consumables.consumablesInfo.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wootide.cms.common.QueryResults;
import com.wootide.cms.log.syslog.RunLog;
import com.wootide.cms.service.consumables.consumablesInfo.dao.ConsumablesReqRecordDao;
import com.wootide.cms.service.consumables.consumablesInfo.pojo.ConsumablesReqRecord;

public class ConsumablesReqRecordDaoImpl extends HibernateDaoSupport implements
        ConsumablesReqRecordDao
{
    /**
     * 运行日志
     */
    private RunLog runLog;
    
    public int findNumByConsumablesReqRecordName(String usePersonName)
    {
        runLog.debug("usePersonName=" + usePersonName);
        
        return ((Number)getHibernateTemplate().findByNamedQuery("findConsumablesReqRecordNumByReqName",
                usePersonName)
                .get(0)).intValue();
    }
    
    
    public QueryResults findConsumablesReqRecordsById(Integer innerIndex)
    {
        runLog.debug("innerIndex" + innerIndex);
        
        QueryResults queryResults = new QueryResults();
        
        queryResults.setResults(getHibernateTemplate().findByNamedQuery("findConsumablesReqRecordById",innerIndex));
        
        return queryResults;
    }
    
    public QueryResults findAllConsumablesInfos()
    {
        QueryResults queryResults = new QueryResults();
        
        queryResults.setResults(getHibernateTemplate().findByNamedQuery("findConsumablesInfos"));
        
        return queryResults;
    }

    @SuppressWarnings("unchecked")
    public ConsumablesReqRecord findOneConsumablesReqRecordByName(
            String usePersonName)
    {
        runLog.debug("usePersonName=" + usePersonName);
        List<ConsumablesReqRecord> list = getHibernateTemplate().findByNamedQuery("findOneConsumableReqByReqName",usePersonName);
        
        return list.isEmpty() ? null : (ConsumablesReqRecord)list.get(0);
    }
    
    public ConsumablesReqRecord findOneConsumablesReqRecordByReqRecordId(
            Integer useRecordId)
    {
        runLog.debug("useRecordId=" + useRecordId);
        
        return getHibernateTemplate().get(ConsumablesReqRecord.class, useRecordId);
    }
    
    public void setRunLog(RunLog runLog)
    {
        this.runLog = runLog;
    }
}
